package com.easytopit.Client;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.net.Socket;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class HTTPResponse implements Response {
	private Socket socket;
	Map<String, String> map = new HashMap<String, String>();
	int status;

	public HTTPResponse(Socket socket) {
		this.socket = socket;

	}

	@Override
	public void init() {

	}

	@Override
	public void addHeader(String key, String value) {

		map.put(key, value);

	}

	@Override
	public void setStatus(int status) {
		// printWriter.println("/HTTP/1.1" + status);
		this.status = status;
	}

	@Override
	public PrintWriter getWriter() {

		PrintWriter printWriter = null;
		try {
			OutputStream outputStream = socket.getOutputStream();

			printWriter = new PrintWriter(outputStream, true);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return printWriter;
	}

	@Override
	public OutputStream getOutputStream() {

		OutputStream outputStream = null;
		try {
			outputStream = socket.getOutputStream();

		} catch (IOException e) {
			e.printStackTrace();
		}
		return outputStream;
	}
}